//
//  PCDApiSetNavigationBarColor.m
//  PCDBank
//
//  Created by DK on 2021/2/26.
//  Copyright © 2021 DK. All rights reserved.
//

#import "PCDApiSetNavigationBarColor.h"
#import "PCDBankWebViewController.h"

@implementation PCDApiSetNavigationBarColor

- (void)handler:(id)data andContext:(PCDContext *)context ResponseCallback:(WVJBResponseCallback )responseCallback
{
    PCDBankWebViewController *pageVC = context.viewController;

    NSDictionary *dict = (NSDictionary *)data;
    NSString *frontColor = [dict objectForKey:@"frontColor"];
    NSString *backgroundColor = [dict objectForKey:@"backgroundColor"];
    

    PCDBarItem *titleItem =pageVC.navigationBar.titleItem;
    titleItem.titleColor = [UIColor colorFormString:frontColor];
    pageVC.navigationBar.titleItem = titleItem;
    
    if ([PCDUtil nilOrEmptyString:backgroundColor]) {
        backgroundColor = @"#ffffff";
        pageVC.navigationBar.backgroundImage = nil;
    }else{
        pageVC.navigationBar.backgroundImage = nil;
    }
    
    pageVC.navigationBar.backgroundColor = [UIColor colorFormString:backgroundColor];

    PCDBarButtonItem *backBarButtonItem = pageVC.navigationBar.leftBarButtonItem;
    
    UIImage *backImage =nil;
    if ([frontColor isEqualToString:@"#ffffff"]) {
        backImage =[UIImage imageNamed:@"backWhite"];
    }else{
        backImage =[UIImage imageNamed:@"取消"];
    }
    backBarButtonItem.image = backImage;
    pageVC.navigationBar.leftBarButtonItem = backBarButtonItem;
    
}

@end
